package com.miya.demo.controller;

import com.miya.demo.model.base.BaseResponse;
import com.miya.demo.model.dto.system.UserAddOrUpdateDTO;
import com.miya.demo.service.UserService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 用户控制器
 *
 * @author Caixiaowei
 * @date 2022/08/18
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @ApiOperation(value = "新增/编辑用户")
    @PostMapping("/addOrUpdate")
    public BaseResponse<Void> addOrUpdate(@Valid @RequestBody UserAddOrUpdateDTO userDTO) {
        userService.addOrUpdate(userDTO);
        return BaseResponse.create();
    }
}
